# -*- coding: utf-8 -*-
import unittest
import sys

sys.path.append('../')

from data import *
from reference import Reference
from fingerprint import Fingerprint


class BaseObjectTestCase(unittest.TestCase):
	def setUp(self):
		populateDB()

	def tearDown(self):
		clearDB()


class ReferenceSimpleTestCase(BaseObjectTestCase):
	def runTest(self):
		r = Reference(1) #the first reference see data for info.
		self.assert_(r != None)

class ReferenceBaseTestCase(BaseObjectTestCase):
	def setUp(self):
		BaseObjectTestCase.setUp(self)
		self.r = Reference(1)

class ReferenceNameTestCase(ReferenceBaseTestCase):
	def runTest(self):
		self.assertEqual(self.r.name, reference1['name'])

class ReferenceYearTestCase(ReferenceBaseTestCase):
	def runTest(self):
		self.assertEqual(self.r.year, reference1['year'])

class ReferenceSourceTestCase(ReferenceBaseTestCase):
	def runTest(self):
		self.assertEqual(self.r.source, reference1['source'])

class ReferenceAuthorTestCase(ReferenceBaseTestCase):
	def runTest(self):
		self.assertEqual(self.r.author_name, reference1['author'])


class FingerprintSimpleTestCase(BaseObjectTestCase):
	def runTest(self):
		f = Fingerprint(1) #the first fingerprint see data for info.
		self.assert_(f != None)

class FingerprintBaseTestCase(BaseObjectTestCase):
	def setUp(self):
		BaseObjectTestCase.setUp(self)
		self.f = Fingerprint(1)

class FingerprintFpstrTestCase(FingerprintBaseTestCase):
	def runTest(self):
		self.assertEqual(self.f.fpstr, compound1['fp'])

if __name__=="__main__":
	unittest.main()